package com.mnt.washio.utils.network.ws;

import java.io.IOException;
import java.util.LinkedHashMap;

import org.apache.http.client.ClientProtocolException;

import android.annotation.SuppressLint;
import android.content.Context;

import com.mnt.washio.utils.Statics;
import com.mnt.washio.utils.network.NetworkUtils;
import com.mnt.washio.utils.network.WebServiceCommunicatorListener;

@SuppressLint("SimpleDateFormat")
public class DeleteAddressWSControl extends BaseWSControl {
	private String addressId;

	public DeleteAddressWSControl(Context context,
			WebServiceCommunicatorListener listener, String addressId) {
		super(context, listener, WebServiceFlag.REMOVE_ADDRESS);
		this.addressId = addressId;
	}

	@Override
	protected Object doInBackground(Void... params) {
		// Get local database

		String url = Statics.ADMIN_WS_URL + "account/address/" + addressId;
		LinkedHashMap<String, String> headers = new LinkedHashMap<String, String>();
		LinkedHashMap<String, String> param = new LinkedHashMap<String, String>();
		param.put("addressId", addressId);
		try {
			return NetworkUtils.doDeleteRequest(url, param, headers);

		} catch (ClientProtocolException e) {
			mError = "Cannot connect to network";
			e.printStackTrace();
		} catch (IOException e) {
			mError = "Cannot connect to network";
			e.printStackTrace();
		}
		return null;
	}

}
